/**
 * https://leetcode-cn.com/problems/pascals-triangle/
 * 给定行数, 生成前n行
 * @param numRows 
 */
const generate = (numRows: number): number[][] => {
    // 定义二维数组
    const arr: number[][] = [[1]];


    for (let i = 1; i < numRows; i++) {
        let prev = arr[i - 1]
        // 默认为1
        let inner = [1]

        // 给里层的赋值
        for (let j = 1; j < i; j++) {
            inner.push(prev[j - 1] + prev[j])
        }

        inner.push(1);

        arr.push(inner)
    }

    return arr;
};

console.log(generate(5))